# Copyright (c) 2020 Huawei Technologies Co.,Ltd.
#
# openGauss is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
#          http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
"""This is only a template file that helps
 users implement the web interfaces for DBMind.
 And some implementations are only demonstrations.
"""
import time

from pydantic import BaseModel

from dbmind.common.http import request_mapping, OAuth2
from dbmind.common.http import standardized_api_output
from dbmind.service import web
   
   
@request_mapping('/api/summary/workload_forecasting', methods=['GET'], api=True)
@oauth2.token_authentication()
@standardized_api_output
def workload_forecasting_summary():
    return web.get_forecast_sequence_info(metric_name=None)


@request_mapping('/api/workload_forecasting/sequence/{name}', methods=['GET'], api=True)
@oauth2.token_authentication()
@standardized_api_output
def workload_forecasting_get_metric_sequence(name, start: int = None, end: int = None, step: int = None):
    return web.get_metric_sequence(name, start, end, step)


@request_mapping('/api/workload_forecasting/sequence/forecast/{name}', methods=['GET'], api=True)
@oauth2.token_authentication()
@standardized_api_output
def workload_forecasting_forecast(name: str, start: int = None, end: int = None, step: int = None):
    if start is None and end is None:
        r = web.get_forecast_sequence_info(name)['rows']
        if len(r) > 0:
            rv = web.get_stored_forecast_sequence(name, start_at=int(time.time() * 1000), limit=500)
            return rv
    return web.get_metric_forecast_sequence(name, start, end, step)
	
	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data
	
	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data
	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data
	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data

	
import unittest

from selenium import webdriver

from pageoperation.admin_loginout_main_page import adminlogin
from pageoperation.buyflow_page import makeOrder
from pageoperation.goodshow_page import goodsSimpleSearch, addGoodToCart
from pageoperation.orderman import orderSimpleSearch, openOrder, orderProcess, adminReceiveMoney
from pageoperation.user_loginout_reg import userLogin
from pageoperation.usercenter_page import receiveConfirm
from testdata.basicflow_zs_testdata import buyflow_postpay_data	



	
	
	
	
	
	
	
	
https://gitee.com/opengauss/openGauss-DBMind.git  2026